﻿using System.Collections;
using System.Collections.Generic;

namespace Inovout.Data.Domain
{
    public class DataObjectPagedSet<TModel> : DataObjectSet<TModel>, IDataObjectPagedSet<TModel>, IEnumerable<TModel>
    {
        public long RecordCount { get; private set; }
        public int PageIndex { get; private set; }
        public int PageSize { get; private set; }

        public int PageCount
        {
            get
            {
                return (int)((RecordCount + (long)PageSize - 1) / PageSize);
            }
        }
        public DataObjectPagedSet(IEnumerable<TModel> list, long resultCount, int pageSize, int pageIndex)
            : base(list)
        {
            PageSize = pageSize;
            PageIndex = pageIndex;
            RecordCount = resultCount;
        }
        IEnumerator<TModel> IEnumerable<TModel>.GetEnumerator()
        {
            return base.GetEnumerator();
        }
        IEnumerator IEnumerable.GetEnumerator()
        {
            return base.GetEnumerator();
        }
    }
}
